<%@page import="CloudStorage.Cart"%>
<%@page import="CloudStorage.Database"%>
<%@page import="CloudStorage.File"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%
            int size = 0;
            if (session.getAttribute("cart") != null) {
                size = ((Cart) session.getAttribute("cart")).getSize();
            }
%>
<html>
    <head>
        <title>CloudShare - CheckOut</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="style.css" />
        <link rel="stylesheet" type="text/css" href="search_style.css" />
        <link rel="SHORTCUT ICON" href="images/favicon.ico" />
        <style type="text/css">
            <!--
            #main .inside .block1 {
                text-align: left;
                clear: none;
                float: left;
                margin-left: 250px;
                height: 200px;
            }
            body,td,th {
                color: #64584C;
            }
            a:link {
                color: #F6F1F0;
            }
            .first {
                background-color: #A85C20;
                color: #FFFFFF;
                padding-left: 4px;
            }
#main .inside #blocks .searchbar #search-text table {
	height: 115%;
}
#main .inside #blocks .searchbar {
	background-image:url(images/middle_search.jpg);
	background-repeat:repeat;
	width:1024px;
	height:120%;
	float:left;
	margin-bottom: 5px;
}
            -->
        </style>
    </head>

    <body>
        <div id="header">
            <div class="inside"> <a href="#" class="logo"><img src="images/logo2.gif" alt="" width="131" height="83" /></a>
                <div id="content">

                </div>
                <p class="slogan">Share on Clouds!</p>
                <div id="cart">
                    <ul>
                        <li><a href="downloadcart.jsp"><img alt="cart" src="images/cart.png">  Download Cart (<%=size%>)</a> </li>
                    </ul>
                </div>
                <a href="faq.jsp" class="rss"><img src="images/rss.jpg" alt="" width="39" height="41" /></a>
            </div>
            <div id="menu">
               <% if (session.getAttribute("status") == null) {%>
                <ul>
                    <li><a href="index.jsp"><img src="images/but_home.jpg" alt="" width="148" height="40" /></a></li>
                    <li><a href="login.jsp"><img src="images/but_login.jpg" alt="" width="147" height="40" /></a></li>
                    <li><a href="register.jsp"><img src="images/but_reg.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="downloads.jsp"><img src="images/but_down.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="upload.jsp"><img src="images/but_upload.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="buy.jsp"><img src="images/but_buy.jpg" alt="" width="146" height="40" /></a></li>
                    
                </ul>
				<% } else { %>
                <ul>
                    <li><a href="index.jsp"><img src="images/but_home.jpg" alt="" width="148" height="40" /></a></li>
                    <li><a href="account.jsp"><img src="images/but_account.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="downloads.jsp"><img src="images/but_down.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="upload.jsp"><img src="images/but_upload.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="buy.jsp"><img src="images/but_buy.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="LogoutServlet"><img src="images/but_logout.jpg" alt="" width="147" height="40" /></a></li>
                </ul>
                <%}%>
                
            </div>
            <div class="headimage">
                <img src="images/picture.jpg" alt="" /> </div>
        </div>
        <div class="inside">

        </div>
        <div id="main">
            <div class="inside">

                <% Database database = new Database();
                     if (session.getAttribute("status") != null) {%>
                <div id="cpanel">
                    <h1><img src="images/cpanel.png" width="40" height="20">User panel</h1>
                    <ul>
                        <li></li>
                        <li><img src="images/myaccount-icon.png" width="20" height="20"> <a href="account.jsp">My Account</a></li>
                        <li><img src="images/uploads_icon.png" width="20" height="20" ><a href="myuploads.jsp"> My Uploads</a></li>
                        <li><img src="images/uploadicon.png"><a href="upload.jsp"> Upload File</a></li>
                        <li><img src="images/cart.png" width="20" height="20"><a href="downloadcart.jsp"> Download Cart</a></li>
                        <li><img src="images/buy_icon.png" alt="" width="20" height="20"><a href="buy.jsp">Buy more Space</a></li>
                    </ul>
                    <div id="logout">
                    <span><a href="LogoutServlet"> <img src="images/logout.png"/></a></span>
                    </div>
                </div>
                <%}%>

                <div id="blocks">

                    <div class="searchbar">

                        <h1>Download Cart - Selected Downloads</h1>
                        <div id="search-img"><img src="images/cart-big.png" width="100" height="100"></div>
                        <div id="search-text">
                            <%if ( session.getAttribute("user") == null && session.getAttribute("final step") == null ){%>
                               <form action="CheckOutServlet">
				First Step:
                                <p>
                                Select your method of payment:
                                <input name="method" type="radio" value="Paypal" checked>
				  Paypal
                                <input name="method" type="radio" value="Credit Card" unchecked>
				  Credit Card </p>
                                <table width="400" height="500">
                                    <tr>
                                        <td>
                                            First Name
                                        </td>
                                        <td>
                                            <input type="text">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Last Name
                                        </td>
                                        <td>
                                            <input type="text">
                                        </td>
                                    </tr>
                                    <tr><td>Credit Card Type</td>
                                        <td>
                                            <select name="card" id="select2">
                                                <option>Visa</option>
                                                <option>MasterCard</option>
                                                <option>American Express</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr><td>Credit Card Number</td>
                                        <td>
                                            <input type="text" name="number" size="12">
                                            CCV2<input type="text" size="4">
                                   
                                        </td>
                                    </tr>
                                    <tr>
                                    </tr>
                                    <tr>
                                        <td><a href="downloadcart.jsp"><img src="images/cancel.png"></a> </td>
                                        <td><a href="CheckoutServlet"><img src="images/continue.png"></a></td>
                                    </tr>
                                </table>
                                </form>
                            <%}
                             else {%>
                                <table width="100%" border="0">
                                <tr>
                                    <td class="first">Filename</td>
                                    <td class="first">Category</td>
                                    <td class="first">Type</td>
                                    <td class="first">Price</td>

                                </tr>
                                <tr>
                                    <td>Filename</td>
                                    <td>Category</td>
                                    <td>Type</td>
                                    <td>Price</td>
                                </tr>
                                <%
                                            Cart cart = (Cart) session.getAttribute("cart");

                                            double sum = 0.0;
                                            for (int i = 0; i < cart.getSize(); i++) {
                                                int ownerId = cart.getFile(i).getOwnerId();
                                                String username = database.getUsername(ownerId);
                                                sum += cart.getFile(i).getValue();
                                %>
                                <tr>
                                    <td ><%=cart.getFile(i).getName()%></td>
                                    <td><%=cart.getFile(i).getCategory()%></td>
                                    <td><%=cart.getFile(i).getStatus()%></td>
                                    <td><%=cart.getFile(i).getValue()%></td>
                                </tr>
                                <%}%>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>Total:</td>
                                    <td><%=sum%> </td>

                                </tr>
                                <tr>

                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td><a href="downloadcart.jsp"><img src="images/cancel.png"></a> </td>
                                    <td><a href="CheckoutServlet?amount=<%=sum%>"><img src="images/download.png"></a></td>
                                </tr>
                            </table>
                            <%}%>
                        </div>
                    </div>
                </div>

            </div>


        </div>
    

    <div id="footer">
        <div class="inside">
            <p>CloudShare &copy; 2010   |  Webdesign by Panoylhs &amp; Roumdic S.A.</p>
        </div>
    </div>
</body>
</html>
